package com.Smart.smartscals.DataBase;


import com.Smart.smartscals.Entity.UserInfoEntity;

import android.content.Context;
import android.database.Cursor;
import android.webkit.DateSorter;
/**
 * 用于保存、查询用户信息的类
 * @author Administrator
 *
 */
public class UserInfoUtils {
	private DataBaseService mDataService;
	Context context;
	public UserInfoUtils(Context context){
		this.context = context;
		mDataService = DataBaseService.getInstance(context);

	}
	public void saveUserInfor(UserInfoEntity userInfoEntity){

		String userName = userInfoEntity.getUserName();
		String pwd = userInfoEntity.getPassWord();
		String birThday = userInfoEntity.getBirthday();
		String sex = userInfoEntity.getSex();
		String height = userInfoEntity.getHeight();

		mDataService.insertUserInfo(userName, pwd, birThday, sex, height);

	}
	public UserInfoEntity getLastUserEntity(){
		UserInfoEntity userInfoEntity = new UserInfoEntity();
		Cursor cursor = mDataService.getLastUser();
		while(cursor.moveToLast()){
			userInfoEntity.setUserName(cursor.getString(cursor.getColumnIndex("userName")));
			userInfoEntity.setPassWord(cursor.getString(cursor.getColumnIndex("passWord")));
			userInfoEntity.setBirthday(cursor.getString(cursor.getColumnIndex("birthday")));
			userInfoEntity.setSex(cursor.getString(cursor.getColumnIndex("userSex")));
			userInfoEntity.setHeight(cursor.getString(cursor.getColumnIndex("userHeight")));

		}

		return userInfoEntity;
	}

}
